package com.fottas.adware.portal.component;

import com.fottas.adware.portal.config.SendSms;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 短信验证消息的处理者
 */
@Component
@RabbitListener(queues = "adware.sms.cancel")
public class CancelSmsReceiver {
    private static Logger LOGGER = LoggerFactory.getLogger(CancelSmsReceiver.class);
    @Autowired
    private SendSms sendSms;
    @RabbitHandler
    public void handle(Map<String, String> map){
        sendSms.sendSMS(map.get("telephone"),map.get("code"));
        LOGGER.info("process sms:{}",map);
    }
}
